<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>现场服务报告</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<link rel="stylesheet" href="../../../../css/mui.min.css">
		<link rel="stylesheet" href="../../../../css/global.css">
		<link rel="stylesheet" href="../../../../css/style.css">
		<link rel="stylesheet" href="../../../../css/mui.picker.css">
		<link rel="stylesheet" href="../../../../css/mui.poppicker.css">
		<style type="text/css">
			.mui-btn-block{
				font-size: 16px;
				color: #a9a9a9;
				border: 0;
			}
			input.d_ipt{
				padding: 0;
			}
			.selectDate{
				color: #333;
			}
			input[type=number]:disabled {
				opacity: .6;
			}
			textarea:disabled {
				opacity: .6;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 id="title" class="mui-title">现场服务报告</h1>
		</header>
		<div class="mui-content" id="mui-content" style="display: none;">
			<div class="details_con">
				<div>
					<input type="hidden" id="noticeServiceType" />
					<input type="hidden" id="noticeSubServiceType" />
					<input type="hidden" id="reportId" />
					<input type="hidden" id="id" />
					<input type="hidden" id="helpId" />
					<input type="hidden" id="planId" />
					<input type="hidden" id="noticeId" />
					<input type="hidden" id="isWarranty" />
					<input type="hidden" id="enginnerId" />
					<input type="hidden" id="fseName" />
					<input type="hidden" id="divi" />
					<input type="hidden" id="bu" />
					<input type="hidden" id="city" />
					<input type="hidden" id="prov" />
					<!-- MD相关问题 -->
					<input type="hidden" id="mdsign" />
					<input type="hidden" id="quesOne" />
					<input type="hidden" id="quesTwo" />
					<input type="hidden" id="quesThree" />
					<input type="hidden" id="quesFour" />
					<input type="hidden" id="quesFive" />
					<input type="hidden" id="quesFiveone" />

					<!-- 关联日志信息 -->
					<input type="hidden" id="logList" />

					<!-- 培训信息 -->
					<input type="hidden" id="trainType" />
					<input type="hidden" id="trainTypeName" />
					<input type="hidden" id="trainNum" />
					<input type="hidden" id="trainFse" />
					<input type="hidden" id="trainFseCode" />
					<input type="hidden" id="trainHour" />
					<input type="hidden" id="trainStart" />
					<input type="hidden" id="trainEnd" />
					<!--<input type="hidden" id="trainType" />-->
					<input type="hidden" id="trainPlace" />
					<input type="hidden" id="trainPlaceName" />
					<input type="hidden" id="otherPlace" />
					<input type="hidden" id="trainObject" />
					<input type="hidden" id="trainObjectName" />
					<input type="hidden" id="cusLevel" />
					<input type="hidden" id="cusLevelName" />
					<input type="hidden" id="fseLevel" />
					<input type="hidden" id="fseLevelName" />
					<input type="hidden" id="jourHour" />
					<input type="hidden" id="aeFse" />
				</div>
				<div class="clum">
					<span class="name">服务编号</span>
					<span class="txt" id="serviceNo"></span>
				</div>
				<div class="clum">
					<span class="name">服务类型<em class="t_red">*</em></span>
					<input type="hidden" id="serviceType" />
					<span class="txt">
						<button id='serviceTypeName' class="mui-btn mui-btn-block mui-btn-select" type='button' style="color: #333;">请选择</button>
					</span>
				</div>
				<!-- <div class="clum">
					<span class="name">保修性质</span>
					<span class="txt" id="isWarrantyShow"></span>
				</div> -->
				<div class="clum autoHeight">
					<span class="name">故障<em class="t_red">*</em></span>
					<div class="clear"></div>
					<textarea id="problem" class="textarea" placeholder="请输入故障"></textarea>
				</div>
				<div class="clum">
					<span class="name">出发时间</span>
					<button id='startTravelDate' type="button" class="selectDate" disabled="disabled">请选择出发时间</button>
				</div>
				<div class="clum">
					<span class="name">接收任务时间</span>
					<button id='orderReceivedDate' class="selectDate" disabled="disabled">请选择接收任务时间</button>
				</div>
				<div class="clum">
					<span class="name">到达现场时间</span>
					<button id='onSiteData' class="selectDate" disabled="disabled">请选择到达现场时间</button>
				</div>
				<div class="clum">
					<span class="name">工作开始时间</span>
					<button id='startWorkingTime' type="button" class="selectDate" disabled="disabled">请选择工作开始时间</button>
				</div>
				<div class="clum">
					<span class="name">工作结束时间</span>
					<button id='endWorkingTime' type="button" class="selectDate" disabled="disabled">请选择工作结束时间</button>
				</div>
				<div class="clum">
					<span class="name">总工作小时数</span>
					<input type="number" id="totalWorkingHours" class="d_ipt" placeholder="请输入总工作小时数" disabled="disabled" />
				</div>
				<div class="clum">
					<span class="name">总旅途小时数</span>
					<input type="number" id="travelTime" class="d_ipt" placeholder="请输入总旅途小时数" disabled="disabled" />
				</div>
				<div class="clum autoHeight">
					<span class="name">工作过程</span>
					<div class="clear"></div>
					<textarea id="actionTaken" class="textarea" placeholder="请输入工作过程" ></textarea>
				</div>
				<div class="clum">
					<span class="name">收费小时数<em class="t_red">*</em></span>
					<input type="number" id="chargeHours" class="d_ipt" placeholder="请输入收费小时数" />
				</div>
				<div class="clum autoHeight">
					<span class="name">结果<em class="t_red">*</em></span>
					<div class="clear"></div>
					<textarea id="results" class="textarea" placeholder="请输入结果"></textarea>
				</div>
				<div class="clum autoHeight">
					<span class="name">工程师建议</span>
					<div class="clear"></div>
					<textarea id="engineersAdvis" class="textarea" placeholder="请输入工程师建议"></textarea>
				</div>
				<div class="clum autoHeight">
					<span class="name">英文故障描述</span>
					<div class="clear"></div>
					<textarea id="enProblemDescription" class="textarea" placeholder="对于保内维修的备件,要求在“英文故障描述”中用英文详细说明现场发现哪个部件具体什么故障,不能单一的使用”block,error,fault”字样,更不能出现NA,install,replace等非故障类词语."></textarea>
				</div>

				<div class="my-content-cell">
					<div class="inline-block" id="worklog">
						<em>查看关联的日志</em>
						<span class="mui-icon mui-icon-arrowright arrow-right-position"></span>
					</div>
				</div>
				<div class="my-content-cell">
					<div class="inline-block" id="picList">
						<em>图片信息列表</em>
						<span class="mui-icon mui-icon-arrowright arrow-right-position"></span>
					</div>
				</div>
				<div class="my-content-cell">
					<div class="inline-block" id="trainInfo">
						<em>培训信息</em>
						<span class="mui-icon mui-icon-arrowright arrow-right-position"></span>
					</div>
				</div>
				<div class="my-content-cell">
					<div class="inline-block" id="feeInfo">
						<em>服务费用</em>
						<span class="mui-icon mui-icon-arrowright arrow-right-position"></span>
					</div>
				</div>
				<div class="my-content-cell" style="display: none;">
					<div class="inline-block" id="md">
						<em>医疗器械可疑不良事件相关问题</em>
						<span class="mui-icon mui-icon-arrowright arrow-right-position"></span>
					</div>
				</div>
				<div class="btn_box">
					<span id="listPorts" class="fl">备件列表</span>
					<span id="addPorts" class="fr red">添加备件</span>
				</div>
				<div style="height: 50px;"></div>
				<div class="line"></div>
				<div class="clum">
					<span class="name">服务结果<em class="t_red">*</em></span>
					<input type="hidden" id="serviceResults" />
					<span class="txt">
						<button id='serviceResultsName' class="mui-btn mui-btn-block mui-btn-select" type='button'>请选择</button>
					</span>
				</div>
				<div class="clum" style="display: none;">
					<span class="name">中断类型<em class="t_red">*</em></span>
					<input type="hidden" id="suspendType" />
					<span class="txt">
						<button id='suspendTypeName' class="mui-btn mui-btn-block mui-btn-select" type='button'>请选择</button>
					</span>
				</div>
				<div class="clum" style="display: none;">
					<span class="name">中断子类型<em class="t_red">*</em></span>
					<input type="hidden" id="suspendSonType" class="d_ipt" />
					<span class="txt">
						<button id='suspendSonTypeName' class="mui-btn mui-btn-block mui-btn-select" type='button'>请选择</button>
					</span>
				</div>
				<div class="clum autoHeight" style="display: none;">
					<span class="name">工作中断原因<em class="t_red">*</em></span>
					<div class="clear"></div>
					<textarea id="workSuspendReason" class="textarea" placeholder="请输入工作中断原因"></textarea>
				</div>
				<div class="clum" id="eqSignDiv" style="display: none;font-size: 14px;height: auto;">
					<span class="name">仪器贴标选项<em class="t_red">*</em></span>
					<div class="mui-input-row mui-checkbox">
						<input name="eqSign" value="1" type="checkbox" />
						<label>已在设备机身加贴产品中文标签</label>
					</div>
					<div class="mui-input-row mui-checkbox">
						<input name="eqSign" value="2" type="checkbox" />
						<label>已在设备机身加贴非医疗用途标签</label>
					</div>
					<div class="mui-input-row mui-checkbox">
						<input name="eqSign" value="3" type="checkbox" />
						<label>设备外包装袋中未发现任何标签</label>
					</div>
				</div>
				<div class="clum autoHeight" style="display: none;">
					<span class="name">关注说明</span>
					<div class="clear"></div>
					<textarea id="concernReason" class="textarea" placeholder="请输入关注说明"></textarea>
				</div>
				<div class="line"></div>
				<div class="btn_box">
					<button id="saveBtn" class="fl" type="button">保存草稿</button>
					<button id="submitBtn" class="fr red" type="button">正式提交</button>
				</div>
				<div style="height: 50px;"></div>
			</div>
		</div>

		<!-- js代码 start -->

		<!-- 基础js start -->
		<script src="../../../../js/mui.min.js"></script>
		<script src="../../../../js/utils/h.js"></script>
		<script src="../../../../js/constant.js"></script>
		<script src="../../../../js/common.js"></script>
		<script src="../../../../js/utils/base64.js"></script>
		<script src="../../../../js/utils/md5.js"></script>
		<script src="../../../../js/utils/sortMap.js"></script>
		<script src="../../../../js/utils/http.js"></script>
		<script src="../../../../js/app.js"></script>
		<!-- 基础js end -->
		<script src="../../../../js/utils/rolldate.min.js"></script>
		<script src="../../../../js/mui.picker.js"></script>
		<script src="../../../../js/mui.poppicker.js"></script>
		<script src="../../../../js/sqliteTools.js"></script>
		<script src="../../../../js/fse/service/report/fieldservice/fieldservice.js"></script>
		<script type="text/javascript" charset="utf-8">
			/* 解决 IOS input 聚焦时，页面整个被推上去了，键盘收起页面未下移 BUG */
			(/iphone|ipod|ipad/i.test(navigator.appVersion)) && document.addEventListener(
				'blur',
				event => {
						// 当页面没出现滚动条时才执行，因为有滚动条时，不会出现这问题
						// input textarea 标签才执行，因为 a 等标签也会触发 blur 事件
					if (
						document.documentElement.offsetHeight <=
						document.documentElement.clientHeight &&
						['input', 'textarea'].includes(event.target.localName)
					) {
						document.body.scrollIntoView() // 回顶部
					}
				},
				true
			)
			/**
			  app.jumpTo("view/service/report/fieldservice/report.html",
			  	"view/service/report/fieldservice/report.html", {
			  		serviceNo: "1087408",
			  		reportId: "34",
			  		planId: 2,
			  		noticeId: 3,
			  		isWarranty: '保外',
			  		serviceType: '安装',
			  		divi: 'LSC',
			  		bu: 'ICLC',
			  		city: '上海',
			  		prov: '上海市',
					problem: '123123',
					mdsign: 0
			  	})
		
			 */
			
			// 提交状态 0未提交 1已提交
			var submitStatus = 0;
			
			/*
			* 禁止交互事件
			*/
			function noInteraction() {
				if(submitStatus && submitStatus == '1') {
					h('#serviceTypeName').attr('disabled', 'disabled')
					h('#serviceTypeName').css({'color':'#a9a9a9'}) //可能语法不对，报错了
					h('#startTravelDate').attr('disabled', 'disabled')
					h('#orderReceivedDate').attr('disabled', 'disabled')
					h('#onSiteData').attr('disabled', 'disabled')
					h('#startWorkingTime').attr('disabled', 'disabled')
					h('#endWorkingTime').attr('disabled', 'disabled')
					h('#serviceResultsName').attr('disabled', 'disabled')
					h('#suspendTypeName').attr('disabled', 'disabled')
					h('#suspendSonTypeName').attr('disabled', 'disabled')
					h('#totalWorkingHours').attr('disabled', 'disabled')
					h('#travelTime').attr('disabled', 'disabled')
					// h('#actionTaken').attr('readonly', 'readonly')

					h('#problem').attr('readonly', 'readonly')
					h('#chargeHours').attr('readonly', 'readonly')
					h('#results').attr('readonly', 'readonly')
					h('#engineersAdvis').attr('readonly', 'readonly')
					h('#enProblemDescription').attr('readonly', 'readonly')
					h('#workSuspendReason').attr('readonly', 'readonly')
					h('#concernReason').attr('readonly', 'readonly')
					
					var checkboxs = document.getElementsByName('eqSign');
					for(var i = 0 ; i< checkboxs.length; i++)
					{
					    var checkbox = checkboxs[i];
					    checkbox.disabled = true;
					}
					
					
					h('#addPorts').hide()
					h('#saveBtn').hide()
					h('#submitBtn').hide()
				}
			}
			
			(function($, doc) {
				$.init();

				$.plusReady(function() {
					var self = plus.webview.currentWebview();
					// 获取上一个页面传过来的参数并显示到页面
					submitStatus = self.submitStatus
					noInteraction()
					var serviceNo = self.serviceNo;
					h('#serviceNo').html(self.serviceNo);
					h('#planId').val(self.planId);
					h('#noticeId').val(self.noticeId);
					var helpId = new Date().UUID(self.serviceNo);
					h('#helpId').val(helpId);

					h('#isWarranty').val(self.isWarranty)
					// h('#isWarrantyShow').html(self.isWarranty) //不显示保修性质
					
					var reportId = self.reportId;
					h('#reportId').val(reportId);
					if (!JS.IsNullOrEmpty(self.problem)) {
						h('#problem').val(self.problem)
					}
					h('#noticeSubServiceType').val(self.subServiceType)
					h('#noticeServiceType').val(self.serviceType)
					h('#serviceTypeName').html(self.serviceType);

					// edit by wlf 20200522 for循环外添加if  为修复：184 若是安装（服务通知的服务大类），则显示安装。见截图64
					if (self.serviceType != "安装"){
						for(var i=0; i < serviceTypeDict.length; i++) {
							if (serviceTypeDict[i].text == self.serviceType) {
								h('#serviceType').val(serviceTypeDict[i].value)
								break;
							}
						}

						h('#serviceTypeName').css({color:'#8E8E93'})
					} else {
						h('#serviceTypeName').css({color:'#8E8E93'});
						h('#serviceType').val(self.serviceType)
					}
					if (self.subServiceType == "安装" || self.isWarranty == "保内") {
						h('#feeInfo').parent().hide()
					}
					h('#divi').val(self.divi);
					h('#bu').val(self.bu);
					h('#city').val(self.city);
					h('#prov').val(self.prov);
					var mdsign = self.mdsign;
					h('#mdsign').val(mdsign);
					console.log(self.serviceType)
					console.log(self.subServiceType)
					console.log(mdsign)
					if (self.serviceType == "维修" && self.subServiceType == "维修" && mdsign > 0) {
						h('#md').parent().show()
					}
					var enginnerId = app.getUser().enginnerId
					
					
					initClickEvent()
					
					var divi = h('#divi').val();
					if (divi == 'LSC' || divi == 'ESC' || divi == 'HSC') {
						
					} else {
						h('#serviceTypeName').attr('disabled', 'disabled')
					}
					if (self.serviceType == "安装") {
						h('#serviceTypeName').html("安装")
						h('#serviceType').val("安装")
					} else {
						h('#serviceTypeName').html(h('#isWarranty').val())
						h('#serviceType').val(h('#isWarranty').val())
					}
					
					viewReport(serviceNo, enginnerId, reportId);
					
					//为修复107 工作过程readonly 点击后不应弹出软键盘
					// h('#actionTaken').tap(function() {
					// 	app.hideSoftKeybord();
					// });
				});
			}(mui, document));

			/**
			 * md相关问题添加或修改成功后更新数据到主报告页面
			 * 
			 * @param {Object} serviceReportId
			 * @param {Object} enginnerId
			 * @param {Object} quesOne
			 * @param {Object} quesTwo
			 * @param {Object} quesThree
			 * @param {Object} quesFour
			 * @param {Object} quesFive
			 * @param {Object} quesFiveone
			 */
			function updateMd(serviceReportId, enginnerId, quesOne, quesTwo, quesThree, quesFour, quesFive, quesFiveone) {
				h('#id').val(serviceReportId + '')
				h('#enginnerId').val(enginnerId + '')
				h('#quesOne').val(quesOne + '')
				h('#quesTwo').val(quesTwo + '')
				h('#quesThree').val(quesThree + '')
				h('#quesFour').val(quesFour + '')
				h('#quesFive').val(quesFive + '')
				h('#quesFiveone').val(JS.IsNullOrEmpty(quesFiveone) ? '' : quesFiveone + '')
			}

			/**
			 * 更新培训信息
			 * 
			 * @param {Object} trainInfo
			 */
			function updateTrainInfo(trainInfo) {
				trainInfo = JSON.parse(decodeURI(trainInfo));
				h('#id').val(trainInfo.id);
				h('#trainType').val(trainInfo.trainType);
				h('#trainTypeName').val(trainInfo.trainTypeName);
				h('#trainNum').val(trainInfo.trainNum);
				h('#trainFse').val(trainInfo.trainFse);
				h('#trainFseCode').val(trainInfo.trainFseCode);
				h('#trainHour').val(trainInfo.trainHour);
				h('#trainStart').val(trainInfo.trainStart);
				h('#trainEnd').val(trainInfo.trainEnd);
				h('#trainPlace').val(trainInfo.trainPlace);
				h('#trainPlaceName').val(trainInfo.trainPlaceName);
				h('#otherPlace').val(trainInfo.otherPlace);
				h('#trainObject').val(trainInfo.trainObject);
				h('#trainObjectName').val(trainInfo.trainObjectName);
				h('#cusLevel').val(trainInfo.cusLevel);
				h('#cusLevelName').val(trainInfo.cusLevelName);
				h('#fseLevel').val(trainInfo.fseLevel);
				h('#fseLevelName').val(trainInfo.fseLevelName);
				h('#jourHour').val(trainInfo.jourHour);
				h('#aeFse').val(trainInfo.aeFse);
			}
			
			/**
			 * 费用信息保存成功回调
			 * 
			 * @param {Object} id
			 */
			function updataFee(id) {
				h('#id').val(id);
			}
		</script>
		<!-- js代码 end -->

	</body>

</html>
